﻿using LibNiconico.NiconicoApi.Internal;
using LibNiconico.NiconicoApi.Utils;
using NicoView.Model.Service.Comments;
using NicoView.Model.Share.Service.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NicoView.Model.Service.Events
{

    public class NicoCommentEventArgsBase : NicoEventArgs
    {
        public NicoCommentEventArgsBase(INicoCommentClient commentClient)
        {
            CommentClient = commentClient;
        }

        public INicoCommentClient CommentClient;
    }

    public class NicoCommentReceivePeriodEventArgs : NicoCommentEventArgsBase
    {
        public NicoCommentReceivePeriodEventArgs(int count, INicoCommentClient commentClient):base(commentClient)
        {
            Count = count;
        }

        public int Count { get; internal set; }
    }

    public delegate void NicoCommentReceivePeriodHandler(NicoCommentReceivePeriodEventArgs args);

    public class NicoCommentReceiveEventArgs : NicoCommentEventArgsBase
    {
        public NicoCommentReceiveEventArgs(IList<NotifyNicoComment> comments, INicoCommentClient commentClient)
            : base(commentClient)
        {
            Comments = comments;
            
        }

        public IList<NotifyNicoComment> Comments { get; internal set; }

        
    }

    public enum SentResult
    {
        Succeed = 0,
        UnKnownError = 1,
        ThreadError = 2,
        ThicketError = 3,
        PostKeyError = 4,
        CommentBlockError = 5,
        UnDefined = 255
    }

    public delegate void NicoCommentSentResultHandler(NicoCommentSentResultEventArgs args);

    public class NicoCommentSentResultEventArgs:NicoCommentEventArgsBase
    {
        public SentResult Result { get; private set; }

        public NicoCommentSentResultEventArgs(NicoChatResultComment result,INicoCommentClient commentClient)
            : base(commentClient)
        {
            switch (result.Status.Code)
            {
                case NicoChatResultStatusCode.Succeed:
                    Result = SentResult.Succeed;
                    break;

                case NicoChatResultStatusCode.ThreadError:
                    Result = SentResult.ThreadError;
                    break;

                case NicoChatResultStatusCode.TicketError:
                    Result = SentResult.ThicketError;
                    break;

                case NicoChatResultStatusCode.PostKeyError:
                    Result = SentResult.PostKeyError;
                    break;

                case NicoChatResultStatusCode.Locked:
                    Result = SentResult.CommentBlockError;
                    break;

                default:
                    Result = SentResult.UnDefined;
                    break;
            }
        }
    }

    public delegate void NicoCommentReceiveHandler(NicoCommentReceiveEventArgs args);

    public class NicoCommentDisconnectEventArgs : NicoCommentEventArgsBase
    {
        public NicoCommentDisconnectEventArgs(bool disposeRequest, INicoCommentClient commentClient)
            : base(commentClient)
        {
            DisposeRequest = disposeRequest;
        }

        public bool DisposeRequest { get; set; }
    }

    public delegate void NicoCommentDisconnectRequestHandler(NicoCommentDisconnectEventArgs args);

    public class NicoCommentGetUserRequestEventArgs : NicoEventArgs
    {
        public NicoCommentGetUserRequestEventArgs(string id)
        {
            Id = id;
            User = null;
        }

        public string Id { get; private set; }
        public NotificationNicoUser User { get; set; }
    }

    public delegate void NicoCommentGetUserRequestHandler(NicoCommentGetUserRequestEventArgs args);

    public delegate void NicoCommentThreadHandler(NicoCommentThreadEventArgs args);

    public class NicoCommentThreadEventArgs : NicoEventArgs
    {
        internal NicoCommentThreadEventArgs(DateTime time)
        {
            Time = time;
        }

        public DateTime Time { get; private set; }
    }
    



}
